\n",
"```\n",
"With a clever combination of the parameters we get the ID unique. Think about how the macro gets called and adjust the template code accordingly.\n",
"\n",
"Now let's look at what we need to do for preparing the Live Doc in Polarion:\n",
"\n",
"\n",
"\n",
"The wiki macros you can copy from the documentation. It should look like this\n",
"```html\n",
"\n",
"#set($statusList = [\"doc_open\", \"draft\", \"planned\", \"inReview\"])\n",
"#if ($statusList.contains($document.getStatus().id))\n",
"
\n",
"DON'T REMOVE THIS
\n",
"↓↓↓Below this point all content is autogenerated and will be overwritten↓↓↓\n",
"
\n",
"#end\n",
"
\n",
"```\n",
"\n",
"It is important that the ID matches with the one set in the config and also the class is `c2pAreaStart` for the section initializer and `c2pAreaEnd` for the section end."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to know more about the features and limitations, head into the\n",
"documentation of the configuration for [MA live doc rendering](https://dsd-dbs.github.io/capella-polarion/features/render_documents.html#mixed-authority-mode).\n",
"\n",
"## How to load the current Polarion LiveDoc and update it\n",
"Just the same way like we did in the FA LiveDoc showcase:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"with document_rendering_config_path.open(\"r\", encoding=\"utf8\") as file:\n",
" configs = document_config.read_config_file(file, model)\n",
"\n",
"documents = worker.load_polarion_documents(configs.iterate_documents())\n",
"projects_document_data = renderer.render_documents(configs, documents)\n",
"for project, project_data in projects_document_data.items():\n",
" worker.create_documents(project_data.new_docs, project)\n",
" worker.update_documents(project_data.updated_docs, project)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This brings us to:\n",
"\n",
"\n",
"\n",
"We should enable `context_diagrams` for the referenced work items:"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"# Copyright DB InfraGO AG and contributors\n",
"# SPDX-License-Identifier: Apache-2.0\n",
"\n",
"mixed_authority:\n",
" - template_directory: document_templates\n",
" heading_numbering: True\n",
" project_id: SPT0Test240118\n",
" work_item_layouts:\n",
" _C2P_physicalLink:\n",
" fields_at_start:\n",
" - id\n",
" _C2P_physicalActor:\n",
" fields_at_start:\n",
" - id\n",
" _C2P_physicalComponentNode:\n",
" fields_at_start:\n",
" - id\n",
" fields_at_end:\n",
" - context_diagram\n",
" _C2P_physicalComponentBehavior:\n",
" fields_at_start:\n",
" - id\n",
" fields_at_end:\n",
" - context_diagram\n",
" _C2P_physicalFunction:\n",
" fields_at_start:\n",
" - id\n",
" fields_at_end:\n",
" - context_diagram\n",
" _C2P_physicalPort:\n",
" fields_at_start:\n",
" - id\n",
" sections:\n",
" PCDContent: test-pcd-mixed-auth.html.j2\n",
" instances:\n",
" - polarion_space: MA-Drafts\n",
" polarion_name: Physical Components Description\n",
" params:\n",
" kinds:\n",
" - SOFTWARE\n",
" - HARDWARE\n",
"\n"
]
}
],
"source": [
"document_rendering_config_path = pathlib.Path(\"configs/ma_capella2polarion_document_config.yaml.j2\")\n",
"print(document_rendering_config_path.read_text(encoding=\"utf8\"))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"with document_rendering_config_path.open(\"r\", encoding=\"utf8\") as file:\n",
" configs = document_config.read_config_file(file, model)\n",
"\n",
"documents = worker.load_polarion_documents(configs.iterate_documents())\n",
"projects_document_data = renderer.render_documents(configs, documents)\n",
"for project, project_data in projects_document_data.items():\n",
" worker.create_documents(project_data.new_docs, project)\n",
" worker.update_documents(project_data.updated_docs, project)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This brings us:\n",
"\n",
"\n",
"\n",
"Be advanteagous and define new sections. Iterate over other attributes of the capellambse object and use the [documentation of py-capellambse](https://dsd-dbs.github.io/py-capellambse/code/capellambse.metamodel.html#). "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### How can I investigate the rendered HTML?"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"The purpose of this document is to provide a detailed technical overview of the physical components within its operational context. This document serves as a structured reference to facilitate understanding and collaboration among stakeholders involved in the design, deployment, and maintenance of the component.
\n",
"\n",
"\n",
"Key objectives of this document include:
\n",
"\n",
"\n",
"\n",
" - Contextual Overview: Illustrating the operational and functional context of all Physical Components using diagrams and associated metadata.
\n",
" - Deployed Components: Listing and describing all deployed sub-components categorized by their respective types.
\n",
" - Electrical Interfaces: Summarizing the electrical connections, including port details, cable IDs, and target interfaces, to ensure clarity in connectivity design.
\n",
" - Allocated Functions: Identifying and detailing all functions assigned to the physical component, showcasing its role within the broader physical architecture.
\n",
"
\n",
"\n",
"\n",
"This document is structured to meet the needs of engineers, project managers, and other stakeholders, offering insights into both the component's high-level purpose and its specific technical attributes. It also provides a foundation for future enhancements, troubleshooting, and integration efforts.
\n",
"\n",
"\n",
"By adhering to this structure, this document ensures consistency and traceability in managing the lifecycle of all components, enabling seamless collaboration across teams and domains.
\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
<div class=\"c2pAreaStart\" id=\"PCDContent\">\n",
"#set($statusList = [\"doc_open\", \"draft\", \"planned\", \"inReview\"])\n",
"#if ($statusList.contains($document.getStatus().id))\n",
"<p style=\"font-weight: bold;background-color: #FFFF00;text-align: center;\">\n",
"DON'T REMOVE THIS<br>\n",
"↓↓↓Below this point all content is autogenerated and will be overwritten↓↓↓\n",
"</p>\n",
"#end\n",
"</div>
\n",
"
\n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"
\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"
\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"\n",
"
<div class=\"c2pAreaEnd\" id=\"PCDContent\">\n",
"#set($statusList = [\"doc_open\", \"draft\", \"planned\", \"inReview\"])\n",
"#if ($statusList.contains($document.getStatus().id))\n",
"<p style=\"font-weight: bold;background-color: #FFFF00;text-align: center;\">\n",
"DON'T REMOVE THIS<br>\n",
"↑↑↑Above this point all content is autogenerated and will be overwritten↑↑↑\n",
"</p>\n",
"#end\n",
"</div>
\n",
"
\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"document = projects_document_data[os.environ[\"POLARION_PROJECT\"]].updated_docs[0].document\n",
"print(document.home_page_content.value)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}